package com.itheima.search.controller;


import com.itheima.search.domain.*;
import com.itheima.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private SearchService searchService;

    @PostMapping
    public SearchResult quertNews(@RequestBody SearchParam searchParam) {
        return searchService.query(searchParam);
    }

    @GetMapping("/{newsId}")
    public NewsVO queryNewById(@PathVariable Long newsId) {
        return searchService.queryNewById(newsId);
    }

    @GetMapping("/hot-news")
    public List<NewsVo2> queryHotNews() {
        return searchService.queryHotNews();
    }
}
